package jdo.crud;

import java.io.IOException;
import javax.jdo.PersistenceManager;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import jdo.entity.Velo;
import jdo.pmf.PMF;

/**
 * Servlet implementation class ListServlet
 */
@SuppressWarnings("serial")
public class AddVeloServlet extends HttpServlet {

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,
			IOException {
		PersistenceManager pm = PMF.getPersistenceManager();
		String name = request.getParameter("name");
		String nb_bornes = request.getParameter("nb_bornes");
		String rue = request.getParameter("rue");
		String num_rue = request.getParameter("num_rue");
		String coord_x = request.getParameter("coord_x");
		String coord_y = request.getParameter("coord_y");


		// Create a record
		Velo velo = new Velo(name,nb_bornes,num_rue,rue,coord_x,coord_y);
		pm.makePersistent(velo);
		pm.close();
		response.sendRedirect("/administration.jsp?message=createdOK");
	}

}
